<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>json的用法</title>
</head>
<body>
    <script>
        // var user={
        //     name: "wufan",
        //     age:22,
        //     sex:"男"
        // }
        // var jsonUser = JSON.stringify(user)
        //json 字符串转换为对象(parse解析,解析时要用单引号，需要和内部岔开)
        // var obj = JSON.parse('{"name":"wufan","age":22,"sex":"男"}')

// JSON和js的区别
            // var obj = {a:'hello',b:'hi'};
            // var json = '{"a":"hello","b":"hi"}'

            // var student = {
            //     name:"wufan",
            //     age:22,
            //     run:function(){
            //         console.log(this.name + "run...");
            //     }
            // }
            // var wufan ={
            //     name :"wufan"
            // }
            // // wufan的原型是student(继承：__proto__)
            // wufan.__proto__ = student;

            // function Student(name) {
            //     this.name = name;
            // }
            // Student.prototype.hello = function(){
            //     alert("hello")
            // };
//ES6后=======
            class Student{
                constructor(name){
                    this.name = name;
                }
                hello(){
                    alert("hello")
                }
            }
            class xiaoxuesheng extends Student{
                constructor(name,grade){
                    super(name);
                this.grade = grade;
                }
                myGrade(){
                    alert("我是一名小学生")
                } 
            }
            var xiaohong = new Student("xiaohong");
            var xiaoming = new Student("xiaoming");
    </script>
</body>
</html>